package com.ruoyi.function.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.function.domain.Garage;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.function.domain.Audit;
import com.ruoyi.function.service.IAuditService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提现审核Controller
 * 
 * @author ruoyi
 * @date 2025-03-20
 */
@RestController
@RequestMapping("/function/audit")
public class AuditController extends BaseController
{
    @Autowired
    private IAuditService auditService;

    /**
     * 查询提现审核列表
     */
//    @PreAuthorize("@ss.hasPermi('function:audit:list')")
    @GetMapping("/list")
    public TableDataInfo list(Audit audit)
    {
        startPage();
        List<Audit> list = auditService.selectAuditList(audit);
        return getDataTable(list);
    }

    /**
     * 导出提现审核列表
     */
    @PreAuthorize("@ss.hasPermi('function:audit:export')")
    @Log(title = "提现审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Audit audit)
    {
        List<Audit> list = auditService.selectAuditList(audit);
        ExcelUtil<Audit> util = new ExcelUtil<Audit>(Audit.class);
        util.exportExcel(response, list, "提现审核数据");
    }

    /**
     * 获取提现审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('function:audit:query')")
    @GetMapping(value = "/{auditId}")
    public AjaxResult getInfo(@PathVariable("auditId") Long auditId)
    {
        return success(auditService.selectAuditByAuditId(auditId));
    }

    /**
     * 新增提现审核
     */
//    @PreAuthorize("@ss.hasPermi('function:audit:add')")
    @Log(title = "提现审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Audit audit)
    {
        return toAjax(auditService.insertAudit(audit));
    }

    /**
     * 修改提现审核
     */
    @PreAuthorize("@ss.hasPermi('function:audit:edit')")
    @Log(title = "提现审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Audit audit)
    {
        return toAjax(auditService.updateAudit(audit));
    }

    /**
     * 删除提现审核
     */
    @PreAuthorize("@ss.hasPermi('function:audit:remove')")
    @Log(title = "提现审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{auditIds}")
    public AjaxResult remove(@PathVariable Long[] auditIds)
    {
        return toAjax(auditService.deleteAuditByAuditIds(auditIds));
    }

    /**
     * 审核
     */
    @Log(title = "提现审核", businessType = BusinessType.UPDATE)
    @PutMapping("/check")
    public AjaxResult check(@RequestBody Audit audit)
    {
        return toAjax(auditService.check(audit));
    }
}
